<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="keywords" content="百度地图,百度地图API，百度地图自定义工具，百度地图所见即所得工具" />
    <meta name="description" content="百度地图API自定义地图，帮助用户在可视化操作下生成百度地图" />
    <title>百度地图API自定义地图</title>
    <!--引用百度地图API-->
    <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=yf4FLdenh6YFzjiRhSoBNcWRfgFKA52l"></script>
</head>

<body style="background:#CBE1FF">
<div style="width:600px;margin:auto;">
    要查询的地址：<input id="text_" type="text" value="济南历下" style="margin-right:100px;"/><br/>
    查询结果(经纬度)：<input id="result_" type="text" /><br/>

    <input type="button" value="查询" onclick="searchByStationName();"/>

    <el-button @click="dialogFormVisible = false">取消</el-button>
    <el-button type="primary" @click="handleEdit()">确定</el-button>

    <div id="container"
         style="position: absolute;
                margin-top:30px;
                width: 600px;
                height: 300px;
                top: 50px;
                border: 1px solid gray;
                overflow:hidden;">
    </div>

</div>

<hr/>
</body>




<script type="text/javascript">

    var map = new BMap.Map("container");
    map.centerAndZoom("黑马程序员济南中心", 13);
    map.enableScrollWheelZoom();    //启用滚轮放大缩小，默认禁用
    map.enableContinuousZoom();    //启用地图惯性拖拽，默认禁用

    map.addControl(new BMap.NavigationControl({anchor:BMAP_ANCHOR_TOP_LEFT,type:BMAP_NAVIGATION_CONTROL_LARGE}));  //添加默认缩放平移控件
    map.addControl(new BMap.OverviewMapControl()); //添加默认缩略地图控件
    map.addControl(new BMap.OverviewMapControl({ isOpen: true, anchor: BMAP_ANCHOR_BOTTOM_RIGHT }));   //右下角，打开

    var localSearch = new BMap.LocalSearch(map);
    localSearch.enableAutoViewport(); //允许自动调节窗体大小
    function update(abc) {
        document.getElementById("text_").innerHTML=abc;
        alert(document.getElementById("text_").value);
    }
    function searchByStationName() {
        var lng_lat = "";
        map.clearOverlays();//清空原来的标注
        //获取定位关键字，如果关键字为空，使用默认关键字【黑马程序员济南中心】
        var keyword = document.getElementById("text_").value;
        if(keyword == null || keyword == ''){
            keyword='黑马程序员济南中心';
            document.getElementById("text_").value=keyword;
        }
        localSearch.setSearchCompleteCallback(function (searchResult) {
            //根据地图搜索结果，获取坐标Point
            var poi = searchResult.getPoi(0);
            //展示根据keyword获取的的经纬度
            document.getElementById("result_").value = poi.point.lng + "," + poi.point.lat;
            map.centerAndZoom(poi.point, 13);
            var marker = new BMap.Marker(new BMap.Point(poi.point.lng, poi.point.lat));  // 创建标注，为要查询的地方对应的经纬度
            map.addOverlay(marker);
            var content = document.getElementById("text_").value + "<br/><br/>经度：" + poi.point.lng + "<br/>纬度：" + poi.point.lat;
            var infoWindow = new BMap.InfoWindow("<p style='font-size:14px;'>" + content + "</p>");
            marker.addEventListener("click", function () { this.openInfoWindow(infoWindow); });
            // marker.setAnimation(BMAP_ANIMATION_BOUNCE); //跳动的动画
        });
        localSearch.search(keyword);
    }
    function textIframeParem(paramIframe) {
        document.getElementById("text_").value=paramIframe;
    }
    function textIframe() {
        return document.getElementById("text_").value;
    }
    var vue =new vue({

        methods:{
            handleEdit(){

            }
        }
    })
</script>

</html>